# 获取t_test所有的数据
import pymysql
import pandas as pd

db = pymysql.connect(host='localhost', user='root', password='663666', port=3306, db='btu')
print("数据库连接成功")
cursor = db.cursor()
# 查询demo_btc所有数据
cursor.execute("select time, price from demo_btc")
# 获取表中的全部数据
result = cursor.fetchall()
print(len(result))
df_result = pd.DataFrame(list(result), columns=["time", "price"])
new_cow = []
new_column = []
# 取time列数据
for a in df_result['time']:
    new_cow.append(a)
# 取price列数据
print(new_cow)
for b in df_result['price']:
    new_column.append(b)
print(new_column)

# print(df_result.shape)
# 查看矩阵或者数组的维数
# print(df_result.head())
# 只读取前5行

